package com.ruoyi.statisticalCenter.service.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.statisticalCenter.domain.vo.ScCashFlowVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.statisticalCenter.mapper.ScCashFlowMapper;
import com.ruoyi.statisticalCenter.domain.ScCashFlow;
import com.ruoyi.statisticalCenter.service.IScCashFlowService;
import com.ruoyi.common.core.text.Convert;

/**
 * 现金流水Service业务层处理
 *
 * @author pyx
 * @date 2024-02-27
 */
@Service
public class ScCashFlowServiceImpl implements IScCashFlowService {
    @Autowired
    private ScCashFlowMapper scCashFlowMapper;

    /**
     * 查询现金流水
     *
     * @param id 现金流水主键
     * @return 现金流水
     */
    @Override
    public ScCashFlow selectScCashFlowById(Long id) {
        return scCashFlowMapper.selectScCashFlowById(id);
    }

    /**
     * 查询现金流水列表
     *
     * @param scCashFlowVo 现金流水
     * @return 现金流水
     */
    @Override
    public List<ScCashFlow> selectScCashFlowList(ScCashFlowVo scCashFlowVo) {
        PageHelper.startPage(scCashFlowVo.getPageDate());
        return scCashFlowMapper.selectScCashFlowList(scCashFlowVo);
    }

    /**
     * 新增现金流水
     *
     * @param scCashFlow 现金流水
     * @return 结果
     */
    @Override
    public R insertScCashFlow(ScCashFlow scCashFlow) {
        return scCashFlowMapper.insertScCashFlow(scCashFlow) > 0 ? R.ok("新增流水成功") : R.fail("新增失败");
    }

    /**
     * 修改现金流水
     *
     * @param scCashFlow 现金流水
     * @return 结果
     */
    @Override
    public R updateScCashFlow(ScCashFlow scCashFlow) {
        return scCashFlowMapper.updateScCashFlow(scCashFlow) > 0 ? R.ok("修改流水成功") : R.fail("修改失败");
    }

    /**
     * 批量删除现金流水
     *
     * @param ids 需要删除的现金流水主键
     * @return 结果
     */
    @Override
    public R deleteScCashFlowByIds(String ids) {
        return scCashFlowMapper.deleteScCashFlowByIds(Convert.toStrArray(ids)) > 0 ? R.ok("删除流水成功") : R.fail("删除失败");
    }

    /**
     * 删除现金流水信息
     *
     * @param id 现金流水主键
     * @return 结果
     */
    @Override
    public int deleteScCashFlowById(Long id) {
        return scCashFlowMapper.deleteScCashFlowById(id);
    }
}

